func canCompleteCircuit(gas []int, cost []int) int {
    totalSum := 0
    currSum := 0
    start := 0
    for i:=0; i<len(gas); i++ {
        currSum += gas[i] - cost[i]
        totalSum += gas[i] - cost[i]
        if currSum < 0 {
            start = i + 1
            currSum = 0
        }
    }
    if totalSum < 0 { return -1 }
    return start
}